#include "BasicGameState.h"
#include "..\utils\Log.h"

namespace ds {

BasicGameState::BasicGameState(const std::string& stateName,const std::string& materialName,const std::string& layerName) 
	: GameState(stateName) 
	, m_Material(materialName) 
	, m_TextCounter(0) 
	, m_StateName(stateName) 
	, m_LayerName(layerName)
	, m_NextStateName("") {

		gEngine->addMouseController(this);
		m_Sprites = new SpriteNode(m_StateName+"Sprites",m_Material);
		WorldLayer wl = gEngine->getWorld().getLayerByName(m_LayerName.c_str());
		gEngine->getWorld().attachNode(m_Sprites,wl);	
}

void BasicGameState::OnButtonUp( int button ) {	
	if ( isActive() ) {
		if ( !m_NextStateName.empty() ) {
			LOG(logINFO) << m_StateName << " - switching to " << m_NextStateName;
			gEngine->activateGameState(m_NextStateName);
		}
	}
}

}
